#@ load("openapi.lib.yml", "response", "reference", "type", "array")

paths:
  /collections:
    get:
      tags:
        - collections
      summary: List collections
      description: Get list name of all existing collections
      operationId: get_collections
      responses: #@ response(reference("CollectionsResponse"))

  /collections/{collection_name}:
    get:
      tags:
        - collections
      summary: Collection info
      description: Get detailed information about specified existing collection
      operationId: get_collection
      parameters:
        - name: collection_name
          in: path
          description: Name of the collection to retrieve
          required: true
          schema:
            type: string
      responses: #@ response(reference("CollectionInfo"))

    put:
      tags:
        - collections
      summary: Create collection
      description: Create new collection with given parameters
      operationId: create_collection
      requestBody:
        description: Parameters of a new collection
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCollection"

      parameters:
        - name: collection_name
          in: path
          description: Name of the new collection
          required: true
          schema:
            type: string
        - name: timeout
          in: query
          description: |
            Wait for operation commit timeout in seconds. 
            If timeout is reached - request will return with service error.
          schema:
            type: integer
      responses: #@ response(type("boolean"))

    patch:
      tags:
        - collections
      summary: Update collection parameters
      description: Update parameters of the existing collection
      operationId: update_collection
      requestBody:
        description: New parameters
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateCollection"

      parameters:
        - name: collection_name
          in: path
          description: Name of the collection to update
          required: true
          schema:
            type: string
        - name: timeout
          in: query
          description: |
            Wait for operation commit timeout in seconds. 
            If timeout is reached - request will return with service error.
          schema:
            type: integer
      responses: #@ response(type("boolean"))

    delete:
      tags:
        - collections
      summary: Delete collection
      description: Drop collection and all associated data
      operationId: delete_collection
      parameters:
        - name: collection_name
          in: path
          description: Name of the collection to delete
          required: true
          schema:
            type: string
        - name: timeout
          in: query
          description: |
            Wait for operation commit timeout in seconds. 
            If timeout is reached - request will return with service error.
          schema:
            type: integer
      responses: #@ response(type("boolean"))

  /collections/aliases:
    post:
      tags:
        - collections
      summary: Update aliases of the collections
      operationId: update_aliases
      requestBody:
        description: Alias update operations
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ChangeAliasesOperation"
      parameters:
        - name: timeout
          in: query
          description: |
            Wait for operation commit timeout in seconds. 
            If timeout is reached - request will return with service error.
          schema:
            type: integer
      responses: #@ response(type("boolean"))

  /collections/{collection_name}/index:
    put:
      tags:
        - collections
      summary: Create index for field in collection
      description: Create index for field in collection
      operationId: create_field_index
      parameters:
        - name: collection_name
          in: path
          description: Name of the collection
          required: true
          schema:
            type: string
        - name: wait
          in: query
          description: "If true, wait for changes to actually happen"
          required: false
          schema:
            type: boolean
        - name: ordering
          in: query
          description: "define ordering guarantees for the operation"
          required: false
          schema:
            $ref: "#/components/schemas/WriteOrdering"
      requestBody:
        description: Field name
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateFieldIndex"

      responses: #@ response(reference("UpdateResult"))

  /collections/{collection_name}/index/{field_name}:
    delete:
      tags:
        - collections
      summary: Delete index for field in collection
      description: Delete field index for collection
      operationId: delete_field_index
      parameters:
        - name: collection_name
          in: path
          description: Name of the collection
          required: true
          schema:
            type: string
        - name: field_name
          in: path
          description: Name of the field where to delete the index
          required: true
          schema:
            type: string
        - name: wait
          in: query
          description: "If true, wait for changes to actually happen"
          required: false
          schema:
            type: boolean
        - name: ordering
          in: query
          description: "define ordering guarantees for the operation"
          required: false
          schema:
            $ref: "#/components/schemas/WriteOrdering"
      responses: #@ response(reference("UpdateResult"))

  /collections/{collection_name}/cluster:
    get:
      tags:
        - collections
        - cluster
      summary: Collection cluster info
      description: Get cluster information for a collection
      operationId: collection_cluster_info
      parameters:
        - name: collection_name
          in: path
          description: Name of the collection to retrieve the cluster info for
          required: true
          schema:
            type: string
      responses: #@ response(reference("CollectionClusterInfo"))

    post:
      tags:
        - collections
        - cluster
      summary: Update collection cluster setup
      operationId: update_collection_cluster
      requestBody:
        description: Collection cluster update operations
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ClusterOperations"
      parameters:
        - name: collection_name
          in: path
          description: Name of the collection on which to to apply the cluster update operation
          required: true
          schema:
            type: string
        - name: timeout
          in: query
          description: |
            Wait for operation commit timeout in seconds. 
            If timeout is reached - request will return with service error.
          schema:
            type: integer
      responses: #@ response(type("boolean"))

  /collections/{collection_name}/aliases:
    get:
      tags:
        - collections
      summary: List aliases for collection
      description: Get list of all aliases for a collection
      operationId: get_collection_aliases
      parameters:
        - name: collection_name
          in: path
          description: Name of the collection
          required: true
          schema:
            type: string
      responses: #@ response(reference("CollectionsAliasesResponse"))

  /aliases:
    get:
      tags:
        - collections
      summary: List collections aliases
      description: Get list of all existing collections aliases
      operationId: get_collections_aliases
      responses: #@ response(reference("CollectionsAliasesResponse"))